package com.bigdata.controller;

import com.bigdata.model.AjaxResultList;
import com.bigdata.model.Result;
import com.bigdata.model.SearchModel;
import com.bigdata.mysql.entity.Rmrb;
import com.bigdata.service.mysql.RmrbService;
import com.bigdata.service.mysql.RmrbTableCtnService;
import com.bigdata.service.mysql.RmrbTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/mge/adx")
public class RmrbController {

	@Autowired
	RmrbService rmrbService;
	@Autowired
	RmrbTableService rmrbTableService;
	@Autowired
	RmrbTableCtnService rmrbTableCtnService;

	@RequestMapping("/rmrb/columns")
	@ResponseBody
	public AjaxResultList<Rmrb> queryColumns(SearchModel searchModel) {
		AjaxResultList<Rmrb> res = AjaxResultList.ok();
		Result r = rmrbService.queryColumn(searchModel);
		res.setRows(r.getList());
		return res;
	}

	@RequestMapping("/rmrb/columnsNo")
	@ResponseBody
	public AjaxResultList<Rmrb> queryColumnsNo(SearchModel searchModel) {
		AjaxResultList<Rmrb> res = AjaxResultList.ok();
		Result r = rmrbService.queryColumnNo(searchModel);
		res.setRows(r.getList());
		return res;
	}

	@RequestMapping("/rmrb/query")
	@ResponseBody
	public AjaxResultList<Rmrb> queryPage(SearchModel searchModel) {
		AjaxResultList<Rmrb> res = AjaxResultList.ok();
		Result r = rmrbService.queryPage(searchModel);
		res.setRows(r.getList());
		res.setTotal(r.getTotal());
		res.setPages(r.getPages());
		res.setPage((long) searchModel.getPageNumber());
		return res;
	}

	@RequestMapping("/rmrb/queryTable")
	@ResponseBody
	public AjaxResultList<Rmrb> queryPageTable(SearchModel searchModel) {
		AjaxResultList<Rmrb> res = AjaxResultList.ok();
		Result r = rmrbTableService.queryPage(searchModel);
		res.setRows(r.getList());
		res.setTotal(r.getTotal());
		res.setPages(r.getPages());
		res.setPage((long) searchModel.getPageNumber());
		return res;
	}

	@RequestMapping("/rmrb/queryTablectn")
	@ResponseBody
	public AjaxResultList<Rmrb> queryPageTableCtn(SearchModel searchModel) {
		AjaxResultList<Rmrb> res = AjaxResultList.ok();
		Result r = rmrbTableCtnService.queryPage(searchModel);
		res.setRows(r.getList());
		res.setTotal(r.getTotal());
		res.setPages(r.getPages());
		res.setPage((long) searchModel.getPageNumber());
		return res;
	}
}
